package org.example.controllre;

import org.example.entity.Stu;
import org.example.mapper.S59Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stu")
public class S59Controller {
    @Autowired
    private S59Mapper s59Mapper;

    @GetMapping()
    public List<Stu> getall(){
        return s59Mapper.findAll();
    }

    @PostMapping("/{id}")
    public Stu get(@PathVariable String id){
        return s59Mapper.findById(id).get();
    }

    @DeleteMapping("/{id}")
    public void del(@PathVariable String id){
         s59Mapper.deleteById(id);
    }

    @PostMapping("/all")
    public void add(Stu stu){
        s59Mapper.save(stu);
    }
}
